let Common = {
    formatDate(date, isStart) {//格式化日期 xxxx-xx-xx;
        if (date === "" || !date) {
            return null;
        } else {
            let today = new Date(date);
            let year = today.getFullYear();
            let month = ('0' + (today.getMonth() + 1)).slice(-2);
            let day = ('0' + today.getDate()).slice(-2);
            if (isStart === true) {
                return `${year}-${month}-${day} 00:00:00`;
            } else if (isStart === false) {
                return `${year}-${month}-${day} 23:59:59`;
            }
            return `${year}-${month}-${day}`;
        }
    },
    navigator() {
        if (/(iPhone|iPad|iPod|iOS)/i.test(window.navigator.userAgent)) {
            return 'ios'
        } else if (/(Android)/i.test(window.navigator.userAgent)) {
            return 'android'
        } else {
            return 'pc'
        }
    },
    objToUrlParam(obj) {//obj=>?id=1&name=2
        var urlParamStr = '';
        if (obj.constructor == Object) {
            var cssStr = '';
            for (var key in obj) {
                cssStr += key + '=' + obj[key] + '&';
            }
            urlParamStr = cssStr.substr(0, cssStr.length - 1);
            urlParamStr = !urlParamStr ? '' : '?' + urlParamStr;
        }
        return urlParamStr;
    },
    statusToCode(str) {
        if (str == 'lianxi' || str == 'kaoshi') {
            return 1
        } else if (str == 'quick') {
            return 2
        } else if (str == 'moni') {
            return 3
        }
    },
    formatDuring(mss) {//毫秒转 天时分秒
        var days = parseInt(mss / (1000 * 60 * 60 * 24));
        var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
        var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60));
        var seconds = (mss % (1000 * 60)) / 1000;
        return days + "天" + hours + "时" + minutes + "分" + seconds + "秒 ";
    }

}
export default Common;